const express = require('express');
const router = express.Router();
const Feedback = require('../models/feedback');

// 提交反馈
router.post('/', async (req, res) => {
  try {
    const { content, email } = req.body;

    if (!content) {
      return res.status(400).json({
        success: false,
        message: '反馈内容不能为空'
      });
    }

    // 保存反馈到数据库
    await Feedback.create({ content, email });
    console.log('收到反馈:', { content, email });

    res.json({
      success: true,
      message: '反馈提交成功'
    });
  } catch (error) {
    console.error('处理反馈时出错:', error);
    res.status(500).json({
      success: false,
      message: '提交反馈失败'
    });
  }
});

module.exports = router; 